<!DOCTYPE html>
<html>
<head>
  <!-- 页面meta -->
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>天天快讯后台管理</title>
  <meta name="description" content="天天快讯后台管理">
  <meta name="keywords" content="天天快讯后台管理">
  <meta content="width=device-width,initial-scale=1,maximum-scale=1,sysUser-scalable=no" name="viewport">
  <!-- 引入样式 -->
  <link rel="stylesheet" href="../plugins/elementui/index.css">
  <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="../css/style.css">


  <!-- Theme included stylesheets -->
  <link href="../plugins/quill/quill.snow.css" rel="stylesheet">
  <link href="../plugins/quill/quill.bubble.css" rel="stylesheet">

  <!-- Core build with no theme, formatting, non-essential modules -->
  <link href="../plugins/quill/quill.core.css" rel="stylesheet">
  <!-- Main Quill library -->
  <script src="../plugins/quill/quill.js"></script>
  <!--        <script src="../plugins/quill/quill.core.js"></script>-->
</head>
<body class="hold-transition">
<div id="app">
  <div class="content-header">
    <h1>网站管理<small>视频管理</small></h1>
    <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>网站管理</el-breadcrumb-item>
      <el-breadcrumb-item>视频管理</el-breadcrumb-item>
    </el-breadcrumb>
  </div>
  <div class="app-container">
    <div class="box">
      <div class="filter-container">
        <el-input placeholder="按视频标题或作者查询" v-model="pagination.queryString" style="width: 200px;"
                  class="filter-item"></el-input>
        <el-button @click="findSearchPage()" class="dalfBut">查询</el-button>
        <el-button type="primary" class="butT" @click="handleCreate()">发布视频</el-button>
      </div>
      <el-table size="small" current-row-key="id" :data="dataList" stripe style="width: 100%" stripe highlight-current-row>
        <!--<el-table-column  align="center" label="序号" prop="id"></el-table-column>-->
        <el-table-column label="编号" align="center" prop="videoId">
        </el-table-column>
        <el-table-column label="视频标题" align="center" prop="videoTitle">
        </el-table-column>
        <el-table-column label="视频简介" align="center" prop="summary">
        </el-table-column>
        <el-table-column label="视频链接" align="center" prop="videoUrl">
        </el-table-column>
        <el-table-column label="视频封面" align="center" prop="coverUrl">
        </el-table-column>
        <el-table-column label="评论数量" align="center" prop="commentNum">
        </el-table-column>
        <el-table-column label="播放数量" align="center" prop="playNum">
        </el-table-column>
        <el-table-column label="作者" align="center" prop="userAccount">
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="createTime">
        </el-table-column>
        <el-table-column label="状态" align="center" prop="state">
        </el-table-column>
        <el-table-column label="操作" align="center" class = "caozuo" width="250">
          <template slot-scope="scope">
            <el-button type="success" size="mini" @click="getArticleBody(scope.row)">查看详情</el-button>
            <!-- <el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button> -->

            <el-dialog class="wenzhang"
                       title="视频信息"
                       :visible.sync="dialogVisible"
                       width="70%"
                       :before-close="handleClose">
              <!--                            <input type="text" v-model="article.body">-->
              <!--                            <h1>{{article.title}}</h1>-->
              <p class="biaoti"> 标题：{{video.title}}</p>
              <!--                            <input type="text" v-model="article.title">-->
              <p class="jianjie"> 简介：{{video.summary}}</p>
              <!--                            <input type="text" v-model="article.summary">-->
              <!--                            <input type="text" v-model="article.categoryName">-->
              <p class="neirong"> 内容：{{video.url}}</p>
              <video :src="video.url"></video>
              <el-button @click="unpass()">拒 绝</el-button>
              <el-button type="primary" @click="pass()">通 过</el-button>
              </span>
            </el-dialog>

            <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
            <el-button  type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-container">
        <el-pagination
                class="pagiantion"
                @current-change="handleCurrentChange"
                :current-page="pagination.currentPage"
                :page-size="pagination.pageSize"
                layout="total, prev, pager, next, jumper"
                :total="pagination.total">
        </el-pagination>
      </div>
      <!-- 新增标签弹层 -->
      <div class="add-form">
        <el-dialog title="发布视频" :visible.sync="dialogFormVisible">
          <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right"
                   label-width="100px">
            <el-row>
              <el-col>
                <el-form-item label="视频标题" prop="videoTitle">
                  <el-input v-model="formData.title"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="创建时间" prop="createTime">
                  <el-input v-model="formData.createTime"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="视频链接" prop="videoUrl">
                  <el-input v-model="formData.videoUrl"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="视频封面链接" prop="coverUrl">
                  <el-input v-model="formData.coverUrl"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="时长" prop="duration">
                  <el-input v-model="formData.duration"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="视频简介" prop="summary">
                  <el-input v-model="formData.summary"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="作者" prop="userAccount">
                  <el-input v-model="formData.userAccount"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="视频分类ID" prop="categoryId">
                  <el-input v-model="formData.categoryId"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="点赞数" prop="likeNum">
                  <el-input v-model="formData.likeNum"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="评论数" prop="commentNum">
                  <el-input v-model="formData.commentNum"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="收藏数" prop="collectNum">
                  <el-input v-model="formData.collectNum"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="播放量" prop="playNum">
                  <el-input v-model="formData.playNum  "/>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取消</el-button>
            <el-button type="primary" @click="handleAdd()">确定</el-button>
          </div>
        </el-dialog>
      </div>

      <!-- 编辑标签弹层 -->
      <div class="add-form">
        <el-dialog title="编辑" :visible.sync="dialogFormVisibleEdit">
          <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right"
                   label-width="100px">
            <el-row>
              <el-col>
                <el-form-item label="视频标题" prop="videoTitle">
                  <el-input v-model="formData.title"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="创建时间" prop="createTime">
                  <el-input v-model="formData.createTime"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="视频链接" prop="videoUrl">
                  <el-input v-model="formData.videoUrl"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="视频封面链接" prop="coverUrl">
                  <el-input v-model="formData.coverUrl"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="时长" prop="duration">
                  <el-input v-model="formData.duration"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="视频简介" prop="summary">
                  <el-input v-model="formData.summary"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="作者" prop="userAccount">
                  <el-input v-model="formData.userAccount"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="视频分类ID" prop="categoryId">
                  <el-input v-model="formData.categoryId"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="点赞数" prop="likeNum">
                  <el-input v-model="formData.likeNum"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="评论数" prop="commentNum">
                  <el-input v-model="formData.commentNum"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="收藏数" prop="collectNum">
                  <el-input v-model="formData.collectNum"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="播放量" prop="playNum">
                  <el-input v-model="formData.playNum  "/>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisibleEdit = false">取消</el-button>
            <el-button type="primary" @click="handleEdit()">确定</el-button>
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script src="../plugins/quill/vue-quill-editor.js"></script>
<script>

  var vue = new Vue({
    el: '#app',
    data: {
      // res:JSON.parse(localStorage.getItem('res.data')),
      video:{body:'',title:'',summary:'',categoryName:'',id:''},
      dialogVisible: false,
      activeName: 'first',
      editorOption: {
        theme: 'snow',
        boundary: document.body,
        modules: {
          toolbar: [
            ['bold', 'italic', 'underline', 'strike'],
            ['blockquote', 'code-block'],
            [{'header': 1}, {'header': 2}],
            [{'list': 'ordered'}, {'list': 'bullet'}],
            [{'script': 'sub'}, {'script': 'super'}],
            [{'indent': '-1'}, {'indent': '+1'}],
            [{'direction': 'rtl'}],
            [{'size': ['small', false, 'large', 'huge']}],
            [{'header': [1, 2, 3, 4, 5, 6, false]}],
            [{'color': []}, {'background': []}],
            [{'font': []}],
            [{'align': []}],
            ['clean'],
            ['link', 'image', 'video']
          ]
        },
        placeholder: 'Insert text here ...',
        readOnly: false
      },
      pagination: {//分页相关模型数据
        currentPage: 1,//当前页码
        pageSize: 8,//每页显示的记录数
        total: 0,//总记录数
        queryString: null//查询条件
      },
      dataList: [],//当前页要展示的分页列表数据
      subjectList: [],
      tableData: {},
      fbChoiceList: [{
        content: "",
      }],
      formData: {},//表单数据
      dialogFormVisible: false,//增加表单是否可见
      dialogFormVisibleEdit: false,
      rules: {//校验规则
        title: [{required: true, message: '必填项', trigger: 'blur'}],
        categoryName: [{required: true, message: '必填项', trigger: 'blur'}],
        viewCounts: [{required: true, message: '必填项', trigger: 'blur'}],
        commentCounts: [{required: true, message: '必填项', trigger: 'blur'}],
        authorName: [{required: true, message: '必填项', trigger: 'blur'}],
        summary: [{required: true, message: '必填项', trigger: 'blur'}],
        body: [{required: true, message: '必填项', trigger: 'blur'}],
      }

    },
    //钩子函数，VUE对象初始化完成后自动执行
    created() {
      this.findPage();
    },
    methods: {

      pass(){
        this.dialogVisible = false;
        let myParams = new URLSearchParams()
        myParams.append('id', this.article.id)
        // id = JSON.stringify(this.article.id);
        axios.post("/admin/article/audit", myParams,{
          headers: {
            'content-type': 'application/x-www-form-urlencoded'
          }}
        ).then((res) => {
          if (res.data.success) {
            console.log(res.data.data);
            this.$message({
              message: '审核成功',
              type: 'success'
            });
            this.findPage();
            alert(message);


          } else if (res.data.code !== 200) {
            this.$message({
              message: res.data.msg,
              type: 'fail'
            });
            this.findPage();
          }
        }).catch((error) => {
          if (error == "Error: Request failed with status code 403") {
            this.$message.error("无操作权限");
          }
        });

      }
      ,
      unpass(){
        this.dialogVisible = false;
        let myParams = new URLSearchParams()
        myParams.append('id', this.article.id)
        // id = JSON.stringify(this.article.id);
        axios.post("/admin/article/refuse", myParams,{
          headers: {
            'content-type': 'application/x-www-form-urlencoded'
          }}
        ).then((res) => {
          if (res.data.success) {
            console.log(res.data.data);
            this.$message({
              message: '审核成功',
              type: 'success'
            });
            this.findPage();
            alert(message);


          } else if (res.data.code !== 200) {
            this.$message({
              message: res.data.msg,
              type: 'fail'
            });
            this.findPage();
          }
        }).catch((error) => {
          if (error == "Error: Request failed with status code 403") {
            this.$message.error("无操作权限");
          }
        });

      }
      ,
      handleClose(done) {
        this.$confirm('确认关闭？')
                .then(_ => {
                  done();
                })
                .catch(_ => {});
      },
      handleAvatarSuccess() {

      },
      beforeAvatarUpload() {

      },
      getArticleBody(row){
        this.resetForm();
        this.dialogVisible = true
        this.formData = row;
        axios.post("/admin/article/getBody", this.formData).then((res) => {
          if (res.data.success) {
            console.log(res.data.data);
            this.$message({
              message: '查看成功',
              type: 'success'
            });
            this.article.body=res.data.data.body;
            this.article.summary=res.data.data.summary;
            this.article.categoryName=res.data.data.categoryName;
            this.article.title=res.data.data.title;
            this.article.id=res.data.data.id;

          } else if (res.data.code !== 200) {
            this.$message({
              message: res.data.msg,
              type: 'fail'
            });
            this.findPage();
          }
        }).catch((error) => {
          if (error == "Error: Request failed with status code 403") {
            this.$message.error("无操作权限");
          }
        });
      },
      //编辑
      handleEdit() {
        axios.post("/admin/article/update", this.formData).then((res) => {
          if (res.data.success) {
            this.$message({
              message: '恭喜你，编辑成功',
              type: 'success'
            });
            this.dialogFormVisibleEdit = false;
            this.findPage();
          } else if (res.data.code !== 200) {
            this.$message({
              message: res.data.msg,
              type: 'fail'
            });
            this.findPage();
          }
        }).catch((error) => {
          if (error == "Error: Request failed with status code 403") {
            this.$message.error("无操作权限");
          }
        });
      },
      //添加
      handleAdd() {
        axios.post("/admin/article/add", this.formData).then((res) => {
          if (res.data.success) {
            this.$message({
              message: '恭喜你，添加成功',
              type: 'success'
            });
            this.dialogFormVisible = false;
            this.findPage();
          } else if (res.data.code !== 200) {
            this.$message({
              message: res.data.msg,
              type: 'fail'
            });
            this.findPage();
          }
        }).catch((error) => {
          if (error == "Error: Request failed with status code 403") {
            this.$message.error("无操作权限");
          }
        });
      },
      findSearchPage() {
        this.pagination.currentPage = 1;
        this.findPage();
      },
      //分页查询
      findPage() {
        axios.post("/admin/article/articleList", this.pagination).then((res) => {
          if (res.data.success) {
            this.dataList = res.data.data.list;
            this.pagination.total = res.data.data.total;
          }
        }).catch((error) => {
          if (error == "Error: Request failed with status code 403") {
            this.$message.error("无操作权限");
          }
        });
      },
      // 重置表单
      resetForm() {
        this.formData = {};
        this.subjects = [];
        this.tableData = {};
      },
      // 弹出添加窗口
      handleCreate() {
        this.resetForm();
        this.dialogFormVisible = true;
      },
      // 弹出编辑窗口
      handleUpdate(row) {
        this.resetForm();
        this.dialogFormVisibleEdit = true;
        this.formData = row;
      },
      //切换页码
      handleCurrentChange(currentPage) {
        this.pagination.currentPage = currentPage;
        this.findPage();
      },
      handleDelete(row) {
        this.$confirm('此操作将永久删除该数据和与之关联的数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.get("/admin/article/delete/" + row.id).then((res) => {
            if (res.data.success) {
              this.$message.success("删除成功");
            }
            this.dialogFormVisible = false;
            this.findPage();
          }).catch((error) => {
            if (error == "Error: Request failed with status code 403") {
              this.$message.error("无操作权限");
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });

      }
    }
  });
  Vue.use(window.VueQuillEditor);
</script>
<style>
  .wenzhang{
    width:600px;
  }
  .wenzhang p {
    text-align: left;
  }
  video {
    display: block;
  }
  .biaoti{
    width: 300px;
    /*background: #0abdfe;*/
  }
  .jianjie{
    /*background: #7ca6c5;*/
  }
  .fenlei{
    /*background: #00a7d0;*/
  }
</style>
</html>